home *** CD-ROM | disk | FTP | other *** search
/ Champak 62 / Volume 62 - JOGO DISK .iso / Games / room-maker.swf / scripts / frame_6 / DoAction.as
Text File  |  2008-03-17  |  9KB  |  359 lines

  1. function doMenuAction(itemNum)
  2. {
  3.    if(itemNum == 0)
  4.    {
  5.       attachSubmenu("w",0);
  6.    }
  7.    else if(itemNum == 1)
  8.    {
  9.       attachSubmenu("b",1);
  10.    }
  11.    else if(itemNum == 2)
  12.    {
  13.       attachSubmenu("f",2);
  14.    }
  15.    else if(itemNum == 3)
  16.    {
  17.       attachSubmenu("c",3);
  18.    }
  19.    else if(itemNum == 4)
  20.    {
  21.       attachSubmenu("t",4);
  22.    }
  23.    else if(itemNum == 5)
  24.    {
  25.       attachSubmenu("s",5);
  26.    }
  27.    else if(itemNum == 6)
  28.    {
  29.       attachSubmenu("n",6);
  30.    }
  31.    else if(itemNum == 7)
  32.    {
  33.       attachSubmenu("r",7);
  34.    }
  35. }
  36. function attachSubmenu(item, itemnum)
  37. {
  38.    if(!_root.mc_hittester.hitTest(_root.help))
  39.    {
  40.       var roomStuffDrag = true;
  41.       _root.createEmptyMovieClip("container",0);
  42.       _root.container._x = xPos[itemnum];
  43.       _root.container._y = yPos;
  44.       _root.container.attachMovie("submenu","submenu",1);
  45.       _root.container.submenu._x = xInPos;
  46.       _root.container.submenu._y = yInPos;
  47.       _root.container.submenu._alpha = 80;
  48.       var k = 1;
  49.       i = 0;
  50.       while(i < Hor)
  51.       {
  52.          j = 0;
  53.          while(j < Ver)
  54.          {
  55.             _root.container.submenu.attachMovie(item + k,item + k,k + 100);
  56.             newmc = item + k;
  57.             _root.container.submenu[newmc]._xscale = 28;
  58.             _root.container.submenu[newmc]._yscale = 28;
  59.             _root.container.submenu[newmc]._x = i * xInc + xOffset;
  60.             _root.container.submenu[newmc]._y = j * yInc + yOffset;
  61.             _root.container.submenu[newmc].onRollOver = function()
  62.             {
  63.                this._xscale = 60;
  64.                this._yscale = 60;
  65.             };
  66.             _root.container.submenu[newmc].onRollOut = function()
  67.             {
  68.                this._xscale = 28;
  69.                this._yscale = 28;
  70.             };
  71.             k++;
  72.             j += 1;
  73.          }
  74.          i += 1;
  75.       }
  76.    }
  77. }
  78. function catchMe(myNum, myName, myCat)
  79. {
  80.    if(!_root.mc_hittester.hitTest(_root.room["a" + myName]))
  81.    {
  82.       trace("myNum " + myNum + " myName " + myName + " myCat " + myCat);
  83.       if(myCat == "n")
  84.       {
  85.          counterCats[0] = counterCats[0] + 1;
  86.          trace(counterCats[0] + " nature");
  87.       }
  88.       else if(myCat == "t")
  89.       {
  90.          counterCats[1] = counterCats[1] + 1;
  91.          trace(counterCats[1] + " tr");
  92.       }
  93.       else if(myCat == "a")
  94.       {
  95.          counterCats[2] = counterCats[2] + 1;
  96.          trace(counterCats[2] + " ad");
  97.       }
  98.       else if(myCat == "s")
  99.       {
  100.          counterCats[3] = counterCats[3] + 1;
  101.          trace(counterCats[3] + " sp");
  102.       }
  103.       else if(myCat == "e")
  104.       {
  105.          counterCats[4] = counterCats[4] + 1;
  106.          trace(counterCats[4] + "ent");
  107.       }
  108.       NameString = myName.charAt(0);
  109.       levelNum = 0;
  110.       if(NameString == "w")
  111.       {
  112.          levelNum = 400;
  113.       }
  114.       else if(NameString == "b")
  115.       {
  116.          levelNum = 450;
  117.       }
  118.       else if(NameString == "c")
  119.       {
  120.          levelNum = 500;
  121.       }
  122.       else if(NameString == "t")
  123.       {
  124.          levelNum = 550;
  125.       }
  126.       else if(NameString == "f")
  127.       {
  128.          levelNum = 600;
  129.       }
  130.       else if(NameString == "s")
  131.       {
  132.          levelNum = 650;
  133.       }
  134.       else if(NameString == "n")
  135.       {
  136.          levelNum = 700;
  137.       }
  138.       else if(NameString == "r")
  139.       {
  140.          levelNum = 750;
  141.       }
  142.       _root.room.attachMovie("a" + myName,"a" + myName,myNum + levelNum);
  143.       if(NameString == "w")
  144.       {
  145.          _root.room["a" + myName].gotoAndStop("room1");
  146.       }
  147.    }
  148.    currentClip = _root.room["a" + myName];
  149.    currentClip._x = myNum - 120;
  150.    currentClip._y = myNum;
  151.    currentClip.onPress = currentClip.onDragOver = currentClip.onDragOut = function()
  152.    {
  153.       trace("pressing the current clip");
  154.       var my_x = _root.dummy._x;
  155.       var my_y = _root.dummy._y;
  156.       var mar1 = _root.frame._width / 2;
  157.       var mar2 = _root.frame._height / 2;
  158.       var left = my_x - mar1;
  159.       var right = my_x + mar1;
  160.       var top = my_y - mar2;
  161.       var bottom = my_y + mar2;
  162.       if(!_root.mc_hittester.hitTest(_root.help))
  163.       {
  164.          startDrag(this,1,left,top,right,bottom);
  165.          _root.x += 2;
  166.          this.swapDepths(_root.x);
  167.       }
  168.    };
  169.    currentClip.onRollOver = function()
  170.    {
  171.       if(!_root.mc_hittester.hitTest(_root.help))
  172.       {
  173.          _root.x += 2;
  174.          this.swapDepths(_root.x);
  175.       }
  176.    };
  177.    currentClip.onRelease = function()
  178.    {
  179.       stopDrag();
  180.    };
  181.    currentClip.onEnterFrame = function()
  182.    {
  183.       if(_root.mc_hittester.hitTest(_root.help))
  184.       {
  185.          this.onRelease = function()
  186.          {
  187.             trace("hittester is touching the help");
  188.             stopDrag();
  189.          };
  190.       }
  191.       if(roomStuffDrag == false)
  192.       {
  193.          stopDrag();
  194.          this.onRollOver = this.onReleaseOutside = this.onPress = this.onRelease = this.onDragOver = this.onDragOut = function()
  195.          {
  196.             stopDrag();
  197.          };
  198.       }
  199.       if(this.hitTest(_root.trashcan.hotspot))
  200.       {
  201.          stopDrag();
  202.          _root.trashcan.gotoAndStop("animate");
  203.          removeMovieClip(this);
  204.          _root.s6.start();
  205.          if(myCat == "n")
  206.          {
  207.             counterCats[0]--;
  208.             trace(counterCats[0] + " nature");
  209.          }
  210.          else if(myCat == "t")
  211.          {
  212.             counterCats[1]--;
  213.             trace(counterCats[1] + " tr");
  214.          }
  215.          else if(myCat == "a")
  216.          {
  217.             counterCats[2]--;
  218.             trace(counterCats[2] + " adv");
  219.          }
  220.          else if(myCat == "s")
  221.          {
  222.             counterCats[3]--;
  223.          }
  224.          else if(myCat == "e")
  225.          {
  226.             counterCats[4]--;
  227.          }
  228.       }
  229.    };
  230. }
  231. function calculateCats()
  232. {
  233.    var max = 0;
  234.    maxCats = new Array();
  235.    i = 0;
  236.    while(i < counterCats.length)
  237.    {
  238.       if(counterCats[i] > max)
  239.       {
  240.          max = counterCats[i];
  241.          maxCats = new Array();
  242.          trace(max + " max");
  243.          maxCats[0] = catNames[i];
  244.       }
  245.       else if(counterCats[i] == max)
  246.       {
  247.          maxCats[maxCats.length++] = catNames[i];
  248.          trace(maxCats);
  249.       }
  250.       i++;
  251.    }
  252.    var maxCatsSum = 0;
  253.    i = 0;
  254.    while(i < counterCats.length)
  255.    {
  256.       maxCatsSum += counterCats[i];
  257.       i++;
  258.    }
  259.    if(maxCats.length > 1 && maxCats.length < 3)
  260.    {
  261.       roomStuffDrag = false;
  262.       file = "eclectic1.txt";
  263.       displayText(file);
  264.    }
  265.    else if(maxCatsSum == 0)
  266.    {
  267.       _root.attachMovie("playAgain","playAgain",900);
  268.       roomStuffDrag = true;
  269.       _root.playAgain._x = 295;
  270.       _root.playAgain._y = 245;
  271.       _root.playAgain._alpha = 80;
  272.    }
  273.    else if(maxCats.length > 2 && maxCats.length < 3)
  274.    {
  275.       roomStuffDrag = false;
  276.       file = "eclectic2.txt";
  277.       displayText(file);
  278.    }
  279.    else if(maxCats.length > 3)
  280.    {
  281.       roomStuffDrag = false;
  282.       file = "eclectic3.txt";
  283.       displayText(file);
  284.    }
  285.    else
  286.    {
  287.       file = String(maxCats[0]) + ".txt";
  288.       roomStuffDrag = false;
  289.       displayText(file);
  290.    }
  291. }
  292. function displayText(file)
  293. {
  294.    loadText = new loadVars();
  295.    loadText.load(file);
  296.    loadText.onLoad = function(success)
  297.    {
  298.       if(success)
  299.       {
  300.          _root.designProfile.html = true;
  301.          _root.designProfile.htmlText = this.myNews;
  302.       }
  303.    };
  304. }
  305. stop();
  306. _root.empty_box._visible = false;
  307. _root.frame._visible = false;
  308. _root.movearea._visible = false;
  309. _root.room._x = _root.frame._x;
  310. _root.room._y = _root.frame._y;
  311. _root.room.attachMovie("room1","room1",1);
  312. _root.room.room1.gotoAndStop("intro");
  313. counterCats = [0,0,0,0,0];
  314. catNames = ["nature","travel","adventure","sports","entertainment"];
  315. init();
  316. var yPos = 134;
  317. var Hor = 5;
  318. var Ver = 4;
  319. var xInc = 72;
  320. var yInc = 70;
  321. var xInPos = 0;
  322. var yInPos = 0;
  323. var xOffset = 50;
  324. var yOffset = 50;
  325. xPos = [295,295,230,365,365,365,365,365];
  326. this.onEnterFrame = function()
  327. {
  328.    help.help_btn.onPress = function()
  329.    {
  330.       removeMovieClip("container");
  331.    };
  332.    ratio.text = mySlider.ratio;
  333.    var slider = ratio.text;
  334.    if(Key.isDown(13))
  335.    {
  336.       mySlider.line._xscale = lineLength.text;
  337.    }
  338.    var aa = 7.142857142857143;
  339.    var i = 1;
  340.    while(i <= 14)
  341.    {
  342.       if(slider < i * aa && slider >= (i - 1) * aa)
  343.       {
  344.          var mystep = "p" + i;
  345.          _root.room.room1.gotoAndStop(mystep);
  346.       }
  347.       i++;
  348.    }
  349. };
  350. var string = "";
  351. var levelNum = 0;
  352. finish_btn.onRelease = function()
  353. {
  354.    calculateCats();
  355.    removeMovieClip("container");
  356.    removeMenu();
  357.    _root.gotoAndStop("#p");
  358. };
  359.